package com.zhuqi.acpect;

import com.zhuqi.exception.CodeException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author zhuqi
 * @version 1.0
 * @date 2021/3/26 8:47
 */
@ControllerAdvice
public class CodeExceptionAcpect {


    /**
     * 给前端返回验证码异常
     * @param model
     * @param exception
     * @return
     */
    @ExceptionHandler(CodeException.class)
    public String codeExc(Model model, CodeException exception) {
        model.addAttribute("errorMsg", exception.getMessage());
        return "log";
    }
}
